from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
browser = webdriver.Chrome()
browser.get('https://www.12306.cn/index/')
id_word = "fromStationText"
# 定位到12306的出发地
locator = (By.ID, id_word)
# 强制等待10秒，如果没有返回就自动抛出异常
wait = WebDriverWait(browser, 10).until(EC.presence_of_element_located(locator))
# 清空输入框
input = browser.find_element_by_id(id_word)
input.clear()
input.send_keys("厦门")
time.sleep(3)
browser.close()
